﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using System.ComponentModel.Composition.Hosting;
using System.ComponentModel.Composition;

namespace SilverlightApplication6
{
    public partial class MainPage : UserControl
    {
        [ImportMany]
        public ObservableCollection<IMessage> Messages { get; set; }

        public MainPage()
        {

            var catalog = new PackageCatalog();
            catalog.AddPackage(Package.Current);
            var container = new CompositionContainer(catalog);
            container.ComposeParts(this);

            InitializeComponent();
            LayoutRoot.DataContext = Messages;
        }

    }

    [InheritedExport]
    public interface IMessage { }

    public class SimpleHello : IMessage
    {
        [Import("Text")]
        public string Text { get; set; }
        public override string ToString()
        {
            return Text;
        }
    }

     public class TextProvider  
     {  
         [Export("Text")]  
         public string Text 
         { 
             get 
             { 
                 return "Hello World! -- 6"; 
             } 
         }  
     }

    public class SimpleHola : IMessage
    {
        public override string ToString()
        {
            return "Hola --6 ";
        }
    }
}
